package ltd.dujiabao.capability.domain.capmng.sync.newmodulespec;

import java.util.Map;
import java.util.Optional;

import org.springframework.stereotype.Component;

import ltd.dujiabao.capability.domain.capmng.sync.Predicate;
import ltd.dujiabao.capability.domain.capmng.sync.SyncCapabilityContext;

/**
 * @author : DuJiabao
 * @Project : ddd-capability
 * @Time : 2024/4/9 22:07
 * @Desc :
 */
@Component
public class NewModuleSpecPredicate implements Predicate {
    @Override
    public boolean checkIfNeeded(SyncCapabilityContext context) {
        return Optional.ofNullable(context.getCapability().getModule("features"))
                .map(o -> (Map<String, Boolean>) o)
                .map(features -> features.get("new_module_spec"))
                .orElse(false);
    }
}
